﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Golf_ProductList.aspx.cs"
    Inherits="Golf.WebUI.AdminShow.CommoditiesMmanagement.Golf_ProductList" %>

<%@ Register Assembly="FlexiGrid" Namespace="FlexiGrid" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>产品表</title>
    <link href="../../Script/FlexiGrid/css/contextmenu.css" rel="stylesheet" type="text/css" />
    <link href="../../Script/FlexiGrid/css/main.css" rel="stylesheet" type="text/css" />
    <link href="../../Script/FlexiGrid/css/flexigrid.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        /**********判断是否加载jquey***************/
        window.jQuery || document.write('<script src="../../Script/jquery/jquery-1.4.1-vsdoc.js" type="text/javascript"><\/script>');
    </script>

    <script src="../../Script/ymPrompt/ymPrompt.js" type="text/javascript"></script>

    <link href="../../Script/ymPrompt/skin/bluebar/ymPrompt.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        jQuery(function() {

            //获取浏览器的高度和宽度
            var mainHeight = document.documentElement.clientHeight;
            var mainWidth = document.documentElement.clientWidth;
            //设置常用属性
            tableId = "tblStudentList";
            title = "产品表";
            pageSize = 10;
            //width = mainWidth;
            //height = mainHeight;
            sortorder = "asc";
            width = "auto";
            height = mainHeight - 110;
            ajaxUrl = "../../HttpHandler/Commodities/Golf_ProductList.ashx";
            //设置列名(注意：主键列不用写)
            cells = new Array(
               new cell("产品分类", "Pro_TypeId", 100, true, "left", null),
               new cell("产品品牌", "Pro_BrandTypeId", 100, true, "left", null),
               new cell("产品名称", "Pro_Name", 100, true, "left", null),
               new cell("商品编号", "Pro_Number", 100, true, "left", null),
               new cell("产品购买数", "Pro_BuyNum", 100, true, "left", null),
               new cell("默认图", "Pro_Picture", 100, true, "left", null),
               new cell("小图", "Pro_PicSmall", 100, true, "left", null),
               new cell("大图", "Pro_PicBig", 100, true, "left", null),
               new cell("Seo标题", "Pro_SeoTitle", 100, true, "left", null),
               new cell("产品号数", "Pro_Wood", 100, true, "left", null),
               new cell("节省", "Pro_Save", 100, true, "left", null),
               new cell("市场价", "Pro_MarketPrice", 100, true, "left", null),
               new cell("会员价", "Pro_Price", 100, true, "left", null),
               new cell("促销", "IsPromotion", 100, true, "left", null),
               new cell("促销价", "Pro_PromotionPrice", 100, true, "left", null),
               new cell("促销开始", "PromotionStartTime", 100, true, "left", null),
               new cell("促销结束", "PromotionEndTime", 100, true, "left", null),
               new cell("使用方法", "Pro_Usage", 100, true, "left", null),
               new cell("产品介绍", "Pro_Introduction", 100, true, "left", null),
               new cell("是否显示", "IsShow", 100, true, "left", null),
               new cell("推荐", "isCommend", 100, true, "left", null),
               new cell("添加时间", "Pro_AddTime", 100, true, "left", null),
               new cell("限制购买数量", "LimitBuyNum", 100, true, "left", null),
               new cell("库存数量", "InventoryNum", 100, true, "left", null),
               new cell("是否有货", "IsStock", 100, true, "left", null),
               new cell("产品评论数", "Pro_CommentNum", 100, true, "left", null),
               new cell("管理人员", "AdminId", 100, true, "left", null),
               new cell("上架", "IsGrounding", 100, true, "left", null),
               new cell("评分", "Pro_Star", 100, true, "left", null)
             );
            //设置菜单按钮
            buttons = new Array(
            new button("Add", "添加", "Add"),
           new button("Update", "修改基本信息", "Update"),
           new button("Update_img", "修改图片", "Update"),
           new button("Update_jieshso", "商品 使用方法  商品介绍", "Update"),
           new button("Update_cuxioa", "商品促销修改", "Update"),
           new button("Refresh", "刷新", "Refresh"),
           new button("Delete", "删除", "Delete")
            );
            button_click = function(cmd, grid) {
                if (cmd == "Add") {
                    ymPrompt.win({ message: 'Golf_ProductAdd.aspx', width: 600, height: 500, title: '添加', maxBtn: true, minBtn: true, iframe: true });
                }
                ///介绍
                if (cmd == "Update_jieshso") { 
                    var chk = $("#tblStudentList input:checked");
                    var strIds = "";
                    if (chk.length == 0) {
                        alert("你需要选中后才可以修改");
                    }
                    else if (chk.length == 1) {
                        chk.each(function() {
                            strIds += chk.val();
                        });
                        //根据 条件传递Id
                        ymPrompt.win({ message: 'Golf_Product_shouming.aspx?action=modify_jieshao&id=' + strIds, width: 1000, height: 500, title: '商品 使用方法  商品介绍', maxBtn: true, minBtn: true, iframe: true });
                    }
                }
                // 促销
                if (cmd == "Update_cuxioa") {
                    var chk = $("#tblStudentList input:checked");
                    var strIds = "";
                    if (chk.length == 0) {
                        alert("你需要选中后才可以修改");
                    }
                    else if (chk.length == 1) {
                        chk.each(function() {
                            strIds += chk.val();
                        });
                        //根据 条件传递Id
                        ymPrompt.win({ message: 'Golf_Product_cuxiao.aspx?action=modifyImg&id=' + strIds, width: 1000, height: 500, title: '商品促销修改', maxBtn: true, minBtn: true, iframe: true });
                    }
                }

                //修改图片
                if (cmd == "Update_img") {
                    var chk = $("#tblStudentList input:checked");
                    var strIds = "";
                    if (chk.length == 0) {
                        alert("你需要选中后才可以修改");
                    }
                    else if (chk.length == 1) {
                        chk.each(function() {
                            strIds += chk.val();
                        });
                        //根据 条件传递Id
                        ymPrompt.win({ message: 'Golf_Product_Img.aspx?action=modifyImg&id=' + strIds, width: 1000, height: 500, title: '修改图片', maxBtn: true, minBtn: true, iframe: true });
                    }
                }
                //等于修改
                if (cmd == "Update") {
                    if (confirm("你确定要修改吗？")) {
                        var chk = $("#tblStudentList input:checked");
                        var strIds = "";
                        if (chk.length == 0) {
                            alert("你需要选中后才可以修改");
                        }
                        else if (chk.length == 1) {
                            chk.each(function() {
                                strIds += chk.val();
                            });
                            //根据 条件传递Id
                            ymPrompt.win({ message: 'Golf_ProductModify.aspx?id=' + strIds, width: 600, height: 500, title: '修改基本信息', maxBtn: true, minBtn: true, iframe: true });
                        }
                    }
                }

                if (cmd == "Delete") {
                    if (confirm("你确定要删除吗？")) {
                        var chk = $("#tblStudentList input:checked");
                        var strIds = "";
                        if (chk.length == 0) {
                            alert("你需要选中后才可以删除");
                        }
                        else if (chk.length == 1) {
                            chk.each(function() {
                                strIds += chk.val();
                            });
                            alert(strIds);
                            $.ajax({
                                type: "POST",
                                contentType: "application/x-www-form-urlencoded",
                                url: "Golf_ProductDelete.aspx?" + Math.random(),
                                data: {
                                    "action": "CommentDele",
                                    "id": escape(strIds)
                                },
                                success: function(msg) {
                                    if (msg == '0') {
                                        alert("删除成功！");
                                        //刷新框架
                                        window.parent.frames.main.location.reload();
                                    }
                                    if (msg == '1') {
                                        ymPrompt.alert("删除失败！");
                                    }
                                },
                                error: function(xhr) {
                                    alert(xhr.responseText);
                                }
                            });
                        }
                    }
                }
                //刷新
                if (cmd == "Refresh") {
                    //刷新框架
                    window.parent.frames.main.location.reload();
                }
            }
            //加载FlexiGrid的方法加载数据
            flexiGridLoad();

        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <cc1:FlexiGrid ID="FlexiGrid1" runat="server" />
        <div id="divStudentData">
            <div id="divStudentList">
                <table id="tblStudentList">
                </table>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
